import axios from "./request.js";
import {BASE_URL} from '../config/index.js'
//登录
console.log(BASE_URL)
export const reqLogin = (username, password) => (axios.post(`${BASE_URL}/login`, {username, password}));
//获取商品 列表
export const reqCategoryList = () => (axios.get(`${BASE_URL}/manage/category/list`));

//商品分类列表
// export const reqCategoryList = () => (axios.get(`${BASE_URL}/manage/category/list`))
//新增商品列表
export const reqAddCategory = (categoryName) => (axios.post(`${BASE_URL}/manage/category/add`,{categoryName}));
//修改商品列表
export const reqUpdateCategory = (categoryId,categoryName) => (axios.post(`${BASE_URL}/manage/category/update`,{categoryId,categoryName}));
// 商品管理列表

export const reqProductList = (pageNum, pageSize) => (axios.get(`${BASE_URL}/manage/product/list`,{
	params: {
	        pageNum,
	        pageSize
	    }
}));
// 获取商品详情

export const reqProductInfo = (categoryId) => (axios.get(`${BASE_URL}/manage/category/info`,{
	params: {
	        categoryId
	    }
}));
//商品的详细信息
export const reqProductView = (productId) => (axios.get(`${BASE_URL}/manage/product/info`, {
    params: {productId}
}))
// 更新商品

export const reqProductUpdate = (id,params) => (axios.get(`${BASE_URL}/manage/product/update`,{
	id,params
}));
export const reqProductUpdateStatus = (id,status) => (axios.get(`${BASE_URL}/manage/product/updateStatus`,{
	id,status
}));

//根据图片唯一名删除图片
export const reqDeletePicture = name => (axios.post(`${BASE_URL}/manage/img/delete`, {name}))

//新增商品
export const reqAddProduct = (categoryId, name, price, desc, status, imgs, detail) => (axios.post(`${BASE_URL}/manage/product/add`, {
    categoryId,
    name,
    price,
    desc,
    status,
    imgs,
    detail
}))

//更新商品信息
export const reqUpdateProduct = (categoryId, name, price, desc, status, imgs, detail, _id) => (axios.post(`${BASE_URL}/manage/product/update`, {
    categoryId,
    name,
    price,
    desc,
    status,
    imgs,
    detail,
    _id
}))
// 商品上下架问题
export const reqUpdateStatus = (productId,status) => (axios.post(`${BASE_URL}/manage/product/updateStatus`, {
    productId,
    status
  
}))


export const reqUseList = () => (axios.get(`${BASE_URL}/manage/user/list`))